<?php
/**
 * 测试修改手机号功能
 */

// 模拟微信小程序获取手机号的返回数据
$testData = [
    'code' => 'test_code_123',
    'encryptedData' => 'test_encrypted_data',
    'iv' => 'test_iv'
];

// 模拟请求头
$headers = [
    'Authorization: Bearer test_token_123',
    'Content-Type: application/json'
];

// 构建请求数据
$postData = json_encode($testData);

// 发起请求
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost:8787/v1/user/changePhone');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo "HTTP状态码: $httpCode\n";
echo "响应内容: $response\n";

// 解析响应
$result = json_decode($response, true);
if ($result) {
    echo "解析后的响应:\n";
    print_r($result);
} else {
    echo "响应解析失败\n";
}
?> 